<?php

namespace addons\fankeditor\controller;

use think\addons\Controller;
use app\common\model\Attachment;
class Index extends Controller
{

    public function index()
    {
        $this->error("当前插件暂无前台页面");
    }

    public function attachment()
    {
        $page = $this->request->param('page', 1);
        $marker = $this->request->param('marker', '');
        $fileType = $this->request->param('fileType', 'image');
        $res=Attachment::where('imagetype','not in',['jpg','png','jpeg'])->paginate(20,false,['page'=>$page])->toArray();

        $newdata=[];
        foreach ($res['data'] as $keys=>$value) {
            $newdata[$keys]['height']=$value['imageheight'];;
             $newdata[$keys]['filesize']=$value['filesize'];
              $newdata[$keys]['oriURL']=$value['url'];
              $newdata[$keys]['thumbURL']=$value['url'];
              $newdata[$keys]['name']=$value['filename'];
              $newdata[$keys]['width']=$value['imagewidth'];
        }
        //data = ['height','filesize','oriURL','thumbURL','width']
        return json([
            'code' => '000',
            'count' => 0,
            'data' =>$newdata,
            'extra' => '',
            'page' => 0,
            'pagesize' => 15
        ]);
    }
}
